#include "Arduino.h"
#include "console_example.h"
#include "task.h"

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <string.h>

#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_console.h"
#include "esp_system.h"
#include "esp_log.h"
#define TAG "main"

#include "Task.h"

// 自定义任务类，继承自 Task
class MyTask : public Task {
public:
    MyTask(std::string taskName = "MyTask", uint16_t stackSize = 10000, uint8_t priority = 5)
        : Task(taskName, stackSize, priority) {}

    // 实现纯虚函数 run
    void run(void *data) override {
        int counter = 0;
        while (true) {
            counter++;
            printf("Counter value: %d\n",counter);
            delay(1000); // 延迟 1 秒
        }
        
    }
};


void setup(void)
{
    MyTask myTask("MyTask", 10000, 5);


//   Serial.begin(115200);
    // 初始化控制台
    console_app();

    myTask.setCore(1);
    // 启动任务，并传递计数器指针作为数据
    myTask.start();
    ESP_LOGI("TAG","myTask started");


}


void loop()
{
  delay(1000);
}